babl-palette: fix regression in prefvious commit
authorØyvind Kolås <pippin@gimp.org>
Thu, 17 May 2018 14:24:49 +0000 (16:24 +0200)
committerØyvind Kolås <pippin@gimp.org>
Thu, 17 May 2018 14:25:37 +0000 (16:25 +0200)
The 255.5 factor for storing a double represenation is neccesary for
desired behavior.

babl/babl-palette.c

index 94d214da9d06135deee5c8c03a07ac8c64ba9a3b..a22ea584bf88c88494021639b182b6d9c9d866f6 100644 (file)
@@ -222,7 +222,7 @@ rgba_to_pal (Babl *conversion,
             }
         }
 
-      ((double *) dst)[0] = best_idx / 255.0;
+      ((double *) dst)[0] = best_idx / 255.5;
 
       src += sizeof (double) * 4;
       dst += sizeof (double) * 1;
@@ -278,7 +278,7 @@ rgba_to_pala (Babl *conversion,
             }
         }
 
-      ((double *) dst)[0] = best_idx / 255.0;
+      ((double *) dst)[0] = best_idx / 255.5;
       ((double *) dst)[1] = alpha;
 
       src += sizeof (double) * 4;
@@ -298,7 +298,7 @@ pal_to_rgba (Babl *conversion,
   assert(pal);
   while (n--)
     {
-      int idx = (((double *) src)[0]) * 255.0;
+      int idx = (((double *) src)[0]) * 255.5;
       double *palpx;
 
       if (idx < 0) idx = 0;
@@ -325,7 +325,7 @@ pala_to_rgba (Babl *conversion,
   assert(pal);
   while (n--)
     {
-      int idx      = (((double *) src)[0]) * 255.0;
+      int idx      = (((double *) src)[0]) * 255.5;
       double alpha = (((double *) src)[1]);
       double *palpx;